Skip to content

feat(ui): redact configured secrets from streaming output - #508

Open
imshubham22apr-gif wants to merge 1 commit into
ossf:mainfrom
imshubham22apr-gif:feat/redact-configured-secrets
Open

imshubham22apr-gif wants to merge 1 commit into
ossf:mainfrom
imshubham22apr-gif:feat/redact-configured-secrets

Conversation

@imshubham22apr-gif

Copy link
Copy Markdown
Contributor

Summary

Adds secret redaction utilities and integrates them into MultiTaskProgress to prevent sensitive credentials, passwords, and API keys from leaking into interactive terminal outputs and logged command streams.

Problem

During preparation and run phases, subprocess commands or error outputs from child processes may print logs containing sensitive environment values, database connection credentials, or API keys (such as sk-... LLM keys or internal auth tokens). Without redaction, these strings can be rendered directly to terminal panels or preserved in captured logs.

Solution

  1. Added redact_secrets(text: str, secrets_to_redact: list[str] | set[str] | None = None) -> str in oss_crs.src.utils:
    • Replaces exact matches of secrets with [REDACTED].
    • Filters out empty or short strings (< 4 characters) to guard against over-redaction.
    • Sorts secrets descending by length to ensure longer composite tokens are masked cleanly before substrings.
  2. Extended MultiTaskProgress in oss_crs.src.ui:
    • Added self.secrets_to_redact: list[str] attribute.
    • Updated add_output_line() to automatically redact matching secrets before storing lines or rendering them to headless/live terminal displays.
  3. Added unit tests in oss_crs/tests/unit/test_utils.py verifying:
    • Multiple secrets are replaced with [REDACTED].
    • Handling of empty strings and None.
    • Short strings (< 4 chars) are ignored to avoid false positives.
    • Longest matching secret is replaced first.
  4. Updated CHANGELOG.md under [Unreleased] ### Added.

Testing

  • uv run pytest oss_crs/tests/unit/test_utils.py -k "TestRedactSecrets" (4 passed)
  • uv run ruff check oss_crs/tests/unit/test_utils.py oss_crs/src/ui.py oss_crs/src/utils.py (passed)
  • uv run ruff format --check oss_crs/tests/unit/test_utils.py oss_crs/src/ui.py oss_crs/src/utils.py (passed)
  • uv run pyright oss_crs/tests/unit/test_utils.py oss_crs/src/ui.py oss_crs/src/utils.py (0 errors)

Signed-off-by: imshubham22apr-gif <imshubham.22apr@gmail.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant